/**
 * 
 */
package com.gr.staffpm.notes.activity;

import java.io.Serializable;

import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;

import com.gr.staffpm.datatypes.Task;


/**
 * @author Graham Rhodes 20 Feb 2011 21:24:40
 */
public class ActivityMessage implements Comparable<ActivityMessage>, Serializable {

    private static final long serialVersionUID = 1L;
    private final DateTime timestamp;
    private final String content;
    private final Task task;

    public ActivityMessage(Task task, DateTime timestamp, String content) {
        this.timestamp = timestamp;
        this.content = content;
        this.task = task;
    }

    public DateTime getTimestamp() {
        return timestamp;
    }

    public String getContent() {
        return content;
    }

    public Task getTask() {
        return task;
    }

    @Override
    public String toString() {
        return content + " at " + DateTimeFormat.forPattern("EEEEE, d MMMMM yyyy 'at' HH:mm").print(timestamp);
    }

    /* Compares the timestamps of two ActivityMessages for list sorting
     */
    @Override
    public int compareTo(ActivityMessage other) {
        return this.timestamp.compareTo(other.getTimestamp());
    }

}
